﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

using System.Data.SqlClient;

namespace XEvents.Library
{
    internal struct fn_xe_file_target_read_file
    {
        internal Guid module_guid;
        internal Guid package_guid;
        internal string object_name;
        internal XDocument event_data;
        internal string file_name;
        internal int file_offset;

        internal fn_xe_file_target_read_file(SqlDataReader dr)
        {
            Utilities.IsGuid((dr["module_guid"] == DBNull.Value ? string.Empty : dr["module_guid"]).ToString(), out module_guid);
            Utilities.IsGuid((dr["package_guid"] == DBNull.Value ? string.Empty : dr["package_guid"]).ToString(), out package_guid);
            object_name = (dr["object_name"] == DBNull.Value ? string.Empty : dr["object_name"]).ToString();
            event_data = XDocument.Parse((dr["event_data"] == DBNull.Value ? string.Empty : dr["event_data"]).ToString());
            file_name = (dr["file_name"] == DBNull.Value ? string.Empty : dr["file_name"]).ToString();
            Int32.TryParse((dr["file_offset"] == DBNull.Value ? "-1" : dr["file_offset"]).ToString(), out file_offset);
        }
    }
}
